package com.mhg.collection.bean;

public class Person {
	private String name;
	private int age;
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public int getAge() {
		return age;
	}
	public void setAge(int age) {
		this.age = age;
	}
	public Person(String name, int age) {
		super();
		this.name = name;
		this.age = age;
	}
	public Person() {
		super();
	}
	@Override
	public String toString() {
		return "Person [name=" + name + ", age=" + age + "]";
	}
	public boolean equals(Object obj){
		if(!(obj instanceof Person))
			return false;
		Person p = (Person)obj;
		return this.name.equals(p.name) && this.age  == p.age;
	}
	public int hashCode(){
		return name.hashCode() + age*37;
		/*
		 * Ϊ�˱��������������
		 * ���� �����Ĺ�ϣ��ֵ �� 30 ���� ��20 = 50
		 * ���� �����Ĺ�ϣ��ֵ �� 20 ���� ��30 = 50
		 * */
	}
}
